package o;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageParser.Package;
import android.content.pm.PermissionInfo;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.os.Build.VERSION;
import androidx.annotation.WorkerThread;
import java.io.File;

public class flo {
    private Resources ʻ;
    private final String ˊ;
    private Context ˋ;
    private Context ˎ;
    private flr ˏ;
    private final Package ॱ;
    private final PackageInfo ᐝ;

    private flo(flr o_flr, Context context, File file) {
        this.ˏ = o_flr;
        this.ˋ = context;
        this.ˊ = file.getAbsolutePath();
        this.ॱ = fpa.ˊ(context, file, 4);
        this.ॱ.applicationInfo.metaData = this.ॱ.mAppMetaData;
        this.ᐝ = new PackageInfo();
        this.ᐝ.applicationInfo = this.ॱ.applicationInfo;
        this.ᐝ.applicationInfo.sourceDir = file.getAbsolutePath();
        if (VERSION.SDK_INT >= 28 || (VERSION.SDK_INT == 27 && VERSION.PREVIEW_SDK_INT != 0)) {
            try {
                this.ᐝ.signatures = this.ॱ.mSigningDetails.signatures;
            } catch (Throwable th) {
                PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 64);
                this.ᐝ.signatures = packageInfo.signatures;
            }
        } else {
            this.ᐝ.signatures = this.ॱ.mSignatures;
        }
        this.ᐝ.packageName = this.ॱ.packageName;
        this.ᐝ.versionCode = this.ॱ.mVersionCode;
        this.ᐝ.versionName = this.ॱ.mVersionName;
        this.ᐝ.permissions = new PermissionInfo[0];
        this.ˎ = new b(this);
        this.ʻ = ॱ(context, file);
    }

    public static flo ॱ(flr o_flr, Context context, File file) {
        return new flo(o_flr, context, file);
    }

    @WorkerThread
    private static Resources ॱ(Context context, File file) {
        Resources resources = context.getResources();
        return new Resources(ˊ(context, file), resources.getDisplayMetrics(), resources.getConfiguration());
    }

    private static AssetManager ˊ(Context context, File file) {
        try {
            Object obj = (AssetManager) AssetManager.class.newInstance();
            fmt.ˏ(AssetManager.class, obj, "addAssetPath", file.getAbsolutePath());
            return obj;
        } catch (Exception e) {
            fmq.ˎ("SkinLoadedPlugin.createAssetManager exception: " + e.getMessage());
            return null;
        }
    }

    public String ˋ() {
        return this.ˊ;
    }

    public String ˊ() {
        return this.ॱ.packageName;
    }

    public AssetManager ˏ() {
        return ˎ().getAssets();
    }

    public Resources ˎ() {
        return this.ʻ;
    }

    public void ˊ(Resources resources) {
        this.ʻ = resources;
    }

    public flr ॱ() {
        return this.ˏ;
    }

    public Context ʼ() {
        return this.ˎ;
    }

    public Theme ʻ() {
        Theme newTheme = this.ʻ.newTheme();
        newTheme.applyStyle(fpb.ॱ(this.ॱ.applicationInfo.theme, VERSION.SDK_INT), false);
        return newTheme;
    }
}
